using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web.Services;
using System.Windows.Forms;
using CatalogSystemProxy;
using System.Xml;

namespace CatalogManager
{
	/// <summary>
	/// Summary description for CatalogManager.
	/// </summary>
	public class CatalogManager : System.Windows.Forms.Form
	{
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.ListView Datalist;
		private System.Windows.Forms.TreeView CatalogTree;
		private System.Windows.Forms.Panel statusBarpanel;
		private System.Windows.Forms.Panel Menuespanel;
		private System.Windows.Forms.MainMenu CatalogManagerMenu;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.Splitter Cataogsplitter;
		private System.Windows.Forms.ToolBar CatalogManagertoolBar;
		private System.Windows.Forms.TabControl Searchtab;
		private System.Windows.Forms.TabPage SearchtabPage;
		private System.Windows.Forms.TabPage AdvSearchtabPage;
		private System.Windows.Forms.Splitter Searchsplitter;
		private System.Windows.Forms.StatusBar CatalogManagerstatusBar;
		private System.Windows.Forms.Panel Catalogspanel;
		private System.Windows.Forms.Panel Searchpanel;
		private System.Windows.Forms.Panel Propertiespanel;
		private System.Windows.Forms.ContextMenu CatalogcontextMenu;
		private System.Windows.Forms.MenuItem cltgEdit;
		private System.Windows.Forms.MenuItem ctlgDelete;
		private System.Windows.Forms.MenuItem ctlgSend;
		private System.Windows.Forms.MenuItem ctlgRebuild;
		private System.Windows.Forms.ToolBarButton toolBarBtnNew;
		private System.Windows.Forms.ContextMenu toolBarBtnNewcontextMenu;
		private System.Windows.Forms.ImageList CatalogAssetList;
		private System.Windows.Forms.ToolBarButton toolBarBtnEdit;
		private System.Windows.Forms.ToolBarButton toolBarBtnImport;
		private System.Windows.Forms.ContextMenu toolBarBtnImportcontextMenu;
		private System.Windows.Forms.ContextMenu toolBarExportcontextMenu;
		private System.Windows.Forms.ToolBarButton toolBarBtnExport;
		private System.Windows.Forms.ToolBarButton toolBarBtnDelete;
		private System.Windows.Forms.ToolBarButton toolBarBtnSend;
		private System.Windows.Forms.ToolBarButton toolBarBtnRebuild;
		private System.Windows.Forms.ToolBarButton toolBarBtnRefresh;
		private System.Windows.Forms.ToolBarButton toolBarBtnFind;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton2;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.Label lblListTotal;
		private System.Windows.Forms.Label lblTotalCount;
		private System.Windows.Forms.Button btnNext;
		private System.Windows.Forms.Button btnNextLast;
		private System.Windows.Forms.TextBox txtPages;
		private System.Windows.Forms.Button btnPrevious;
		private System.Windows.Forms.Button btnPreviousLast;
		private System.Windows.Forms.Panel Navpanel;
		private System.Windows.Forms.Label lblPage;
		private System.Windows.Forms.Label lblPageCount;
		private System.Windows.Forms.Label lblSearchCatalogs;
		private System.Windows.Forms.ComboBox cboCatalogs;
		private System.Windows.Forms.TextBox txtKeyWord;
		private System.Windows.Forms.Button btnFindAll;
		private System.Windows.Forms.Button btnFind;
		private System.Windows.Forms.Label lblKeyWords;
		private System.Windows.Forms.ContextMenu ProductcontextMenu;
		private System.Windows.Forms.ContextMenu CategorycontextMenu;
		//private localhost.CatalogSystem CSService = new localhost.CatalogSystem();
		private CatalogSystem CSService = null;
		private System.Windows.Forms.MenuItem ProdFindAll;
		private System.Windows.Forms.MenuItem ProdFind;
		private System.Windows.Forms.MenuItem ProdNew;
		private System.Windows.Forms.MenuItem ProdEdit;
		private System.Windows.Forms.MenuItem ProdDelete;
		private System.Windows.Forms.MenuItem CatEdit;
		private System.Windows.Forms.MenuItem EditDelete;
		private System.Windows.Forms.MenuItem CatNew;
		private System.Windows.Forms.MenuItem CatRefresh;
		private DataSet languages=null;
		private System.Windows.Forms.Button btnNewProduct;
		private System.Windows.Forms.MenuItem menuItemCatalogASets;
		private System.Windows.Forms.MenuItem menuItemCategoryDef;
		private System.Windows.Forms.MenuItem menuItemProductDef;
		private System.Windows.Forms.MenuItem menuItem1PropertyDef;
		private System.Windows.Forms.Panel panelPaging;
		private System.Windows.Forms.ComboBox comboBoxAndOr;
		private System.Windows.Forms.DataGrid dataGridAdvanceSearch;
		private System.Windows.Forms.Button btnDelete;
		private System.Windows.Forms.Button dtnEdit;
		private System.Windows.Forms.Button btnFindNow;
		private System.Windows.Forms.Button btnApply;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.ComboBox comboBoxProductSelector;
		private System.Windows.Forms.ContextMenu contextMenuProductSearch;
		private System.Windows.Forms.ComboBox comboBoxQualifier;
		private System.Windows.Forms.TextBox textBoxSearchWord;
		private System.Windows.Forms.Button buttonNewAdvSearch;
		DataGrid.HitTestInfo SearchHitInfo=null;
		DataSet dsSearch=null;
		DataRow drSearch=null;
		bool editRow=false;
		private bool haveSearchData=false;
		private string SiteName=null;
		private System.Windows.Forms.MenuItem menuItemProduct;
		private const int PAGE_SIZE=20;
		private System.Windows.Forms.ImageList DataListimageList;
		private System.Windows.Forms.Splitter ToolBarsplitter;
		private System.Windows.Forms.ImageList TreeViewimageList;
		private System.Windows.Forms.ContextMenu contextMenuVirtualCatalog;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItem13;
		private System.Windows.Forms.MenuItem menuItemNewBase;
		private System.Windows.Forms.MenuItem menuItemNewVirtual;
		private System.Windows.Forms.MenuItem menuItem1ExportXML;
		private System.Windows.Forms.MenuItem menuItem1ExportCSV;
		private System.Windows.Forms.MenuItem menuItemImportXML;
		private System.Windows.Forms.MenuItem menuItemImportCSV;
		private Paging paging = new Paging();
		
		public CatalogManager()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CatalogManager));
			this.Datalist = new System.Windows.Forms.ListView();
			this.TreeViewimageList = new System.Windows.Forms.ImageList(this.components);
			this.ProductcontextMenu = new System.Windows.Forms.ContextMenu();
			this.ProdFindAll = new System.Windows.Forms.MenuItem();
			this.ProdFind = new System.Windows.Forms.MenuItem();
			this.ProdNew = new System.Windows.Forms.MenuItem();
			this.ProdEdit = new System.Windows.Forms.MenuItem();
			this.ProdDelete = new System.Windows.Forms.MenuItem();
			this.DataListimageList = new System.Windows.Forms.ImageList(this.components);
			this.CatalogTree = new System.Windows.Forms.TreeView();
			this.CatalogcontextMenu = new System.Windows.Forms.ContextMenu();
			this.cltgEdit = new System.Windows.Forms.MenuItem();
			this.ctlgDelete = new System.Windows.Forms.MenuItem();
			this.ctlgSend = new System.Windows.Forms.MenuItem();
			this.ctlgRebuild = new System.Windows.Forms.MenuItem();
			this.statusBarpanel = new System.Windows.Forms.Panel();
			this.CatalogManagerstatusBar = new System.Windows.Forms.StatusBar();
			this.Menuespanel = new System.Windows.Forms.Panel();
			this.CatalogManagertoolBar = new System.Windows.Forms.ToolBar();
			this.toolBarBtnNew = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnNewcontextMenu = new System.Windows.Forms.ContextMenu();
			this.menuItemNewBase = new System.Windows.Forms.MenuItem();
			this.menuItemNewVirtual = new System.Windows.Forms.MenuItem();
			this.toolBarBtnEdit = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnImport = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnImportcontextMenu = new System.Windows.Forms.ContextMenu();
			this.menuItemImportXML = new System.Windows.Forms.MenuItem();
			this.menuItemImportCSV = new System.Windows.Forms.MenuItem();
			this.toolBarBtnExport = new System.Windows.Forms.ToolBarButton();
			this.toolBarExportcontextMenu = new System.Windows.Forms.ContextMenu();
			this.menuItem1ExportXML = new System.Windows.Forms.MenuItem();
			this.menuItem1ExportCSV = new System.Windows.Forms.MenuItem();
			this.toolBarBtnDelete = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnSend = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnRebuild = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnRefresh = new System.Windows.Forms.ToolBarButton();
			this.toolBarBtnFind = new System.Windows.Forms.ToolBarButton();
			this.CatalogAssetList = new System.Windows.Forms.ImageList(this.components);
			this.CatalogManagerMenu = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItemCatalogASets = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItemCategoryDef = new System.Windows.Forms.MenuItem();
			this.menuItemProductDef = new System.Windows.Forms.MenuItem();
			this.menuItem1PropertyDef = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.Catalogspanel = new System.Windows.Forms.Panel();
			this.Cataogsplitter = new System.Windows.Forms.Splitter();
			this.Searchpanel = new System.Windows.Forms.Panel();
			this.Searchtab = new System.Windows.Forms.TabControl();
			this.SearchtabPage = new System.Windows.Forms.TabPage();
			this.lblKeyWords = new System.Windows.Forms.Label();
			this.btnNewProduct = new System.Windows.Forms.Button();
			this.btnFind = new System.Windows.Forms.Button();
			this.btnFindAll = new System.Windows.Forms.Button();
			this.txtKeyWord = new System.Windows.Forms.TextBox();
			this.cboCatalogs = new System.Windows.Forms.ComboBox();
			this.lblSearchCatalogs = new System.Windows.Forms.Label();
			this.AdvSearchtabPage = new System.Windows.Forms.TabPage();
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnApply = new System.Windows.Forms.Button();
			this.btnFindNow = new System.Windows.Forms.Button();
			this.dataGridAdvanceSearch = new System.Windows.Forms.DataGrid();
			this.comboBoxAndOr = new System.Windows.Forms.ComboBox();
			this.textBoxSearchWord = new System.Windows.Forms.TextBox();
			this.comboBoxQualifier = new System.Windows.Forms.ComboBox();
			this.comboBoxProductSelector = new System.Windows.Forms.ComboBox();
			this.contextMenuProductSearch = new System.Windows.Forms.ContextMenu();
			this.menuItemProduct = new System.Windows.Forms.MenuItem();
			this.buttonNewAdvSearch = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.dtnEdit = new System.Windows.Forms.Button();
			this.Searchsplitter = new System.Windows.Forms.Splitter();
			this.Propertiespanel = new System.Windows.Forms.Panel();
			this.panelPaging = new System.Windows.Forms.Panel();
			this.Navpanel = new System.Windows.Forms.Panel();
			this.lblPageCount = new System.Windows.Forms.Label();
			this.lblPage = new System.Windows.Forms.Label();
			this.lblListTotal = new System.Windows.Forms.Label();
			this.lblTotalCount = new System.Windows.Forms.Label();
			this.txtPages = new System.Windows.Forms.TextBox();
			this.btnPrevious = new System.Windows.Forms.Button();
			this.btnNextLast = new System.Windows.Forms.Button();
			this.btnNext = new System.Windows.Forms.Button();
			this.btnPreviousLast = new System.Windows.Forms.Button();
			this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
			this.CategorycontextMenu = new System.Windows.Forms.ContextMenu();
			this.CatEdit = new System.Windows.Forms.MenuItem();
			this.EditDelete = new System.Windows.Forms.MenuItem();
			this.CatNew = new System.Windows.Forms.MenuItem();
			this.CatRefresh = new System.Windows.Forms.MenuItem();
			this.ToolBarsplitter = new System.Windows.Forms.Splitter();
			this.contextMenuVirtualCatalog = new System.Windows.Forms.ContextMenu();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem13 = new System.Windows.Forms.MenuItem();
			this.statusBarpanel.SuspendLayout();
			this.Menuespanel.SuspendLayout();
			this.Catalogspanel.SuspendLayout();
			this.Searchpanel.SuspendLayout();
			this.Searchtab.SuspendLayout();
			this.SearchtabPage.SuspendLayout();
			this.AdvSearchtabPage.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGridAdvanceSearch)).BeginInit();
			this.Propertiespanel.SuspendLayout();
			this.panelPaging.SuspendLayout();
			this.Navpanel.SuspendLayout();
			this.SuspendLayout();
			// 
			// Datalist
			// 
			this.Datalist.Dock = System.Windows.Forms.DockStyle.Fill;
			this.Datalist.FullRowSelect = true;
			this.Datalist.MultiSelect = false;
			this.Datalist.Name = "Datalist";
			this.Datalist.Size = new System.Drawing.Size(661, 222);
			this.Datalist.SmallImageList = this.TreeViewimageList;
			this.Datalist.TabIndex = 2;
			this.Datalist.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Datalist_MouseUp);
			// 
			// TreeViewimageList
			// 
			this.TreeViewimageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
			this.TreeViewimageList.ImageSize = new System.Drawing.Size(16, 16);
			this.TreeViewimageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("TreeViewimageList.ImageStream")));
			this.TreeViewimageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// ProductcontextMenu
			// 
			this.ProductcontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																							   this.ProdFindAll,
																							   this.ProdFind,
																							   this.ProdNew,
																							   this.ProdEdit,
																							   this.ProdDelete});
			// 
			// ProdFindAll
			// 
			this.ProdFindAll.Index = 0;
			this.ProdFindAll.Text = "Find All Products";
			this.ProdFindAll.Click += new System.EventHandler(this.FindAllProduct);
			// 
			// ProdFind
			// 
			this.ProdFind.Index = 1;
			this.ProdFind.Text = "Find a Product";
			this.ProdFind.Click += new System.EventHandler(this.FindProduct);
			// 
			// ProdNew
			// 
			this.ProdNew.Index = 2;
			this.ProdNew.Text = "New Product";
			this.ProdNew.Click += new System.EventHandler(this.NewProduct);
			// 
			// ProdEdit
			// 
			this.ProdEdit.Index = 3;
			this.ProdEdit.Text = "Edit Product";
			this.ProdEdit.Click += new System.EventHandler(this.EditProduct);
			// 
			// ProdDelete
			// 
			this.ProdDelete.Index = 4;
			this.ProdDelete.Text = "Delete Product";
			// 
			// DataListimageList
			// 
			this.DataListimageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
			this.DataListimageList.ImageSize = new System.Drawing.Size(16, 16);
			this.DataListimageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("DataListimageList.ImageStream")));
			this.DataListimageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// CatalogTree
			// 
			this.CatalogTree.Dock = System.Windows.Forms.DockStyle.Fill;
			this.CatalogTree.HotTracking = true;
			this.CatalogTree.ImageList = this.TreeViewimageList;
			this.CatalogTree.Name = "CatalogTree";
			this.CatalogTree.Size = new System.Drawing.Size(168, 406);
			this.CatalogTree.TabIndex = 0;
			this.CatalogTree.MouseUp += new System.Windows.Forms.MouseEventHandler(this.CatalogTree_MouseUp);
			this.CatalogTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.CatalogTree_AfterSelect);
			// 
			// CatalogcontextMenu
			// 
			this.CatalogcontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																							   this.cltgEdit,
																							   this.ctlgDelete,
																							   this.ctlgSend,
																							   this.ctlgRebuild});
			// 
			// cltgEdit
			// 
			this.cltgEdit.Index = 0;
			this.cltgEdit.Text = "Edit Properties";
			this.cltgEdit.Click += new System.EventHandler(this.Edit_Properties);
			// 
			// ctlgDelete
			// 
			this.ctlgDelete.Index = 1;
			this.ctlgDelete.Text = "Delete Catlaog";
			this.ctlgDelete.Click += new System.EventHandler(this.Delte);
			// 
			// ctlgSend
			// 
			this.ctlgSend.Index = 2;
			this.ctlgSend.Text = "Send";
			this.ctlgSend.Click += new System.EventHandler(this.Send);
			// 
			// ctlgRebuild
			// 
			this.ctlgRebuild.Index = 3;
			this.ctlgRebuild.Text = "Rebuild";
			this.ctlgRebuild.Click += new System.EventHandler(this.Rebuild);
			// 
			// statusBarpanel
			// 
			this.statusBarpanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																						 this.CatalogManagerstatusBar});
			this.statusBarpanel.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.statusBarpanel.Location = new System.Drawing.Point(0, 441);
			this.statusBarpanel.Name = "statusBarpanel";
			this.statusBarpanel.Size = new System.Drawing.Size(832, 32);
			this.statusBarpanel.TabIndex = 3;
			// 
			// CatalogManagerstatusBar
			// 
			this.CatalogManagerstatusBar.Dock = System.Windows.Forms.DockStyle.Fill;
			this.CatalogManagerstatusBar.Name = "CatalogManagerstatusBar";
			this.CatalogManagerstatusBar.ShowPanels = true;
			this.CatalogManagerstatusBar.Size = new System.Drawing.Size(832, 32);
			this.CatalogManagerstatusBar.TabIndex = 0;
			// 
			// Menuespanel
			// 
			this.Menuespanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																					  this.CatalogManagertoolBar});
			this.Menuespanel.Dock = System.Windows.Forms.DockStyle.Top;
			this.Menuespanel.Name = "Menuespanel";
			this.Menuespanel.Size = new System.Drawing.Size(832, 32);
			this.Menuespanel.TabIndex = 5;
			// 
			// CatalogManagertoolBar
			// 
			this.CatalogManagertoolBar.AutoSize = false;
			this.CatalogManagertoolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																									 this.toolBarBtnNew,
																									 this.toolBarBtnEdit,
																									 this.toolBarBtnImport,
																									 this.toolBarBtnExport,
																									 this.toolBarBtnDelete,
																									 this.toolBarBtnSend,
																									 this.toolBarBtnRebuild,
																									 this.toolBarBtnRefresh,
																									 this.toolBarBtnFind});
			this.CatalogManagertoolBar.Dock = System.Windows.Forms.DockStyle.Fill;
			this.CatalogManagertoolBar.DropDownArrows = true;
			this.CatalogManagertoolBar.ImageList = this.CatalogAssetList;
			this.CatalogManagertoolBar.Name = "CatalogManagertoolBar";
			this.CatalogManagertoolBar.ShowToolTips = true;
			this.CatalogManagertoolBar.Size = new System.Drawing.Size(832, 32);
			this.CatalogManagertoolBar.TabIndex = 0;
			this.CatalogManagertoolBar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
			this.CatalogManagertoolBar.Wrappable = false;
			this.CatalogManagertoolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.CatalogManagertoolBar_ButtonClick);
			// 
			// toolBarBtnNew
			// 
			this.toolBarBtnNew.DropDownMenu = this.toolBarBtnNewcontextMenu;
			this.toolBarBtnNew.ImageIndex = 0;
			this.toolBarBtnNew.Pushed = true;
			this.toolBarBtnNew.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
			this.toolBarBtnNew.Text = "New";
			// 
			// toolBarBtnNewcontextMenu
			// 
			this.toolBarBtnNewcontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																									 this.menuItemNewBase,
																									 this.menuItemNewVirtual});
			// 
			// menuItemNewBase
			// 
			this.menuItemNewBase.Index = 0;
			this.menuItemNewBase.Text = "New Base Catalog";
			this.menuItemNewBase.Click += new System.EventHandler(this.menuItemNewBase_Click);
			// 
			// menuItemNewVirtual
			// 
			this.menuItemNewVirtual.Index = 1;
			this.menuItemNewVirtual.Text = "New Virtual Catalog";
			this.menuItemNewVirtual.Click += new System.EventHandler(this.menuItemNewVirtual_Click);
			// 
			// toolBarBtnEdit
			// 
			this.toolBarBtnEdit.ImageIndex = 2;
			this.toolBarBtnEdit.Text = "Edit Properties";
			// 
			// toolBarBtnImport
			// 
			this.toolBarBtnImport.DropDownMenu = this.toolBarBtnImportcontextMenu;
			this.toolBarBtnImport.ImageIndex = 3;
			this.toolBarBtnImport.Pushed = true;
			this.toolBarBtnImport.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
			this.toolBarBtnImport.Text = "Import";
			// 
			// toolBarBtnImportcontextMenu
			// 
			this.toolBarBtnImportcontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																										this.menuItemImportXML,
																										this.menuItemImportCSV});
			// 
			// menuItemImportXML
			// 
			this.menuItemImportXML.Index = 0;
			this.menuItemImportXML.Text = "Import XML";
			this.menuItemImportXML.Click += new System.EventHandler(this.menuItemImportXML_Click);
			// 
			// menuItemImportCSV
			// 
			this.menuItemImportCSV.Index = 1;
			this.menuItemImportCSV.Text = "Import CSV";
			this.menuItemImportCSV.Click += new System.EventHandler(this.menuItemImportCSV_Click);
			// 
			// toolBarBtnExport
			// 
			this.toolBarBtnExport.DropDownMenu = this.toolBarExportcontextMenu;
			this.toolBarBtnExport.ImageIndex = 7;
			this.toolBarBtnExport.Pushed = true;
			this.toolBarBtnExport.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
			this.toolBarBtnExport.Text = "Export";
			// 
			// toolBarExportcontextMenu
			// 
			this.toolBarExportcontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																									 this.menuItem1ExportXML,
																									 this.menuItem1ExportCSV});
			// 
			// menuItem1ExportXML
			// 
			this.menuItem1ExportXML.Index = 0;
			this.menuItem1ExportXML.Text = "Export XML";
			this.menuItem1ExportXML.Click += new System.EventHandler(this.menuItem1ExportXML_Click);
			// 
			// menuItem1ExportCSV
			// 
			this.menuItem1ExportCSV.Index = 1;
			this.menuItem1ExportCSV.Text = "Export CSV";
			this.menuItem1ExportCSV.Click += new System.EventHandler(this.menuItem1ExportCSV_Click);
			// 
			// toolBarBtnDelete
			// 
			this.toolBarBtnDelete.ImageIndex = 4;
			this.toolBarBtnDelete.Text = "Delete";
			// 
			// toolBarBtnSend
			// 
			this.toolBarBtnSend.ImageIndex = 5;
			this.toolBarBtnSend.Text = "Send";
			// 
			// toolBarBtnRebuild
			// 
			this.toolBarBtnRebuild.ImageIndex = 8;
			this.toolBarBtnRebuild.Text = "Rebuild";
			// 
			// toolBarBtnRefresh
			// 
			this.toolBarBtnRefresh.ImageIndex = 9;
			this.toolBarBtnRefresh.Text = "Refresh";
			// 
			// toolBarBtnFind
			// 
			this.toolBarBtnFind.ImageIndex = 6;
			this.toolBarBtnFind.Text = "Find";
			// 
			// CatalogAssetList
			// 
			this.CatalogAssetList.ColorDepth = System.Windows.Forms.ColorDepth.Depth16Bit;
			this.CatalogAssetList.ImageSize = new System.Drawing.Size(23, 22);
			this.CatalogAssetList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("CatalogAssetList.ImageStream")));
			this.CatalogAssetList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// CatalogManagerMenu
			// 
			this.CatalogManagerMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																							   this.menuItem1,
																							   this.menuItem2});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItemCatalogASets,
																					  this.menuItem4});
			this.menuItem1.Text = "File";
			// 
			// menuItemCatalogASets
			// 
			this.menuItemCatalogASets.Index = 0;
			this.menuItemCatalogASets.Text = "Catalog Sets";
			this.menuItemCatalogASets.Click += new System.EventHandler(this.menuItemCatalogASets_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 1;
			this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItemCategoryDef,
																					  this.menuItemProductDef,
																					  this.menuItem1PropertyDef});
			this.menuItem4.Text = "Catalog Definiton Designer";
			// 
			// menuItemCategoryDef
			// 
			this.menuItemCategoryDef.Index = 0;
			this.menuItemCategoryDef.Text = "Category Defintion";
			this.menuItemCategoryDef.Click += new System.EventHandler(this.menuItemCategoryDef_Click);
			// 
			// menuItemProductDef
			// 
			this.menuItemProductDef.Index = 1;
			this.menuItemProductDef.Text = "Product Definition";
			this.menuItemProductDef.Click += new System.EventHandler(this.menuItemProductDef_Click);
			// 
			// menuItem1PropertyDef
			// 
			this.menuItem1PropertyDef.Index = 2;
			this.menuItem1PropertyDef.Text = "Property Definition";
			this.menuItem1PropertyDef.Click += new System.EventHandler(this.menuItem1PropertyDef_Click);
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 1;
			this.menuItem2.Text = "Help";
			// 
			// Catalogspanel
			// 
			this.Catalogspanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																						this.CatalogTree});
			this.Catalogspanel.Dock = System.Windows.Forms.DockStyle.Left;
			this.Catalogspanel.Location = new System.Drawing.Point(0, 35);
			this.Catalogspanel.Name = "Catalogspanel";
			this.Catalogspanel.Size = new System.Drawing.Size(168, 406);
			this.Catalogspanel.TabIndex = 7;
			// 
			// Cataogsplitter
			// 
			this.Cataogsplitter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.Cataogsplitter.Location = new System.Drawing.Point(168, 35);
			this.Cataogsplitter.Name = "Cataogsplitter";
			this.Cataogsplitter.Size = new System.Drawing.Size(3, 406);
			this.Cataogsplitter.TabIndex = 8;
			this.Cataogsplitter.TabStop = false;
			// 
			// Searchpanel
			// 
			this.Searchpanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																					  this.Searchtab});
			this.Searchpanel.Dock = System.Windows.Forms.DockStyle.Top;
			this.Searchpanel.Location = new System.Drawing.Point(171, 35);
			this.Searchpanel.Name = "Searchpanel";
			this.Searchpanel.Size = new System.Drawing.Size(661, 149);
			this.Searchpanel.TabIndex = 9;
			this.Searchpanel.Visible = false;
			// 
			// Searchtab
			// 
			this.Searchtab.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.SearchtabPage,
																					this.AdvSearchtabPage});
			this.Searchtab.Dock = System.Windows.Forms.DockStyle.Fill;
			this.Searchtab.Name = "Searchtab";
			this.Searchtab.SelectedIndex = 0;
			this.Searchtab.Size = new System.Drawing.Size(661, 149);
			this.Searchtab.TabIndex = 0;
			this.Searchtab.Visible = false;
			// 
			// SearchtabPage
			// 
			this.SearchtabPage.Controls.AddRange(new System.Windows.Forms.Control[] {
																						this.lblKeyWords,
																						this.btnNewProduct,
																						this.btnFind,
																						this.btnFindAll,
																						this.txtKeyWord,
																						this.cboCatalogs,
																						this.lblSearchCatalogs});
			this.SearchtabPage.Location = new System.Drawing.Point(4, 22);
			this.SearchtabPage.Name = "SearchtabPage";
			this.SearchtabPage.Size = new System.Drawing.Size(653, 123);
			this.SearchtabPage.TabIndex = 0;
			this.SearchtabPage.Text = "Search";
			// 
			// lblKeyWords
			// 
			this.lblKeyWords.Location = new System.Drawing.Point(16, 40);
			this.lblKeyWords.Name = "lblKeyWords";
			this.lblKeyWords.Size = new System.Drawing.Size(100, 16);
			this.lblKeyWords.TabIndex = 8;
			this.lblKeyWords.Text = "Key Words:";
			// 
			// btnNewProduct
			// 
			this.btnNewProduct.Location = new System.Drawing.Point(336, 88);
			this.btnNewProduct.Name = "btnNewProduct";
			this.btnNewProduct.Size = new System.Drawing.Size(80, 23);
			this.btnNewProduct.TabIndex = 5;
			this.btnNewProduct.Text = "New Product";
			this.btnNewProduct.Click += new System.EventHandler(this.NewProduct);
			// 
			// btnFind
			// 
			this.btnFind.Location = new System.Drawing.Point(248, 88);
			this.btnFind.Name = "btnFind";
			this.btnFind.Size = new System.Drawing.Size(80, 23);
			this.btnFind.TabIndex = 4;
			this.btnFind.Text = "Find";
			this.btnFind.Click += new System.EventHandler(this.FindProduct);
			// 
			// btnFindAll
			// 
			this.btnFindAll.Location = new System.Drawing.Point(160, 88);
			this.btnFindAll.Name = "btnFindAll";
			this.btnFindAll.Size = new System.Drawing.Size(80, 23);
			this.btnFindAll.TabIndex = 3;
			this.btnFindAll.Text = "Find All";
			this.btnFindAll.Click += new System.EventHandler(this.FindAllProduct);
			// 
			// txtKeyWord
			// 
			this.txtKeyWord.Location = new System.Drawing.Point(128, 40);
			this.txtKeyWord.Name = "txtKeyWord";
			this.txtKeyWord.Size = new System.Drawing.Size(392, 20);
			this.txtKeyWord.TabIndex = 2;
			this.txtKeyWord.Text = "";
			// 
			// cboCatalogs
			// 
			this.cboCatalogs.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboCatalogs.Location = new System.Drawing.Point(128, 8);
			this.cboCatalogs.Name = "cboCatalogs";
			this.cboCatalogs.Size = new System.Drawing.Size(392, 21);
			this.cboCatalogs.TabIndex = 1;
			// 
			// lblSearchCatalogs
			// 
			this.lblSearchCatalogs.Location = new System.Drawing.Point(16, 16);
			this.lblSearchCatalogs.Name = "lblSearchCatalogs";
			this.lblSearchCatalogs.Size = new System.Drawing.Size(100, 16);
			this.lblSearchCatalogs.TabIndex = 0;
			this.lblSearchCatalogs.Text = "Search Catalogs:";
			// 
			// AdvSearchtabPage
			// 
			this.AdvSearchtabPage.Controls.AddRange(new System.Windows.Forms.Control[] {
																						   this.btnCancel,
																						   this.btnApply,
																						   this.btnFindNow,
																						   this.dataGridAdvanceSearch,
																						   this.comboBoxAndOr,
																						   this.textBoxSearchWord,
																						   this.comboBoxQualifier,
																						   this.comboBoxProductSelector,
																						   this.buttonNewAdvSearch,
																						   this.btnDelete,
																						   this.dtnEdit});
			this.AdvSearchtabPage.Location = new System.Drawing.Point(4, 22);
			this.AdvSearchtabPage.Name = "AdvSearchtabPage";
			this.AdvSearchtabPage.Size = new System.Drawing.Size(653, 123);
			this.AdvSearchtabPage.TabIndex = 1;
			this.AdvSearchtabPage.Text = "Advance Search";
			// 
			// btnCancel
			// 
			this.btnCancel.Enabled = false;
			this.btnCancel.Location = new System.Drawing.Point(368, 96);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 20;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnApply
			// 
			this.btnApply.Enabled = false;
			this.btnApply.Location = new System.Drawing.Point(280, 96);
			this.btnApply.Name = "btnApply";
			this.btnApply.TabIndex = 19;
			this.btnApply.Text = "Apply";
			this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
			// 
			// btnFindNow
			// 
			this.btnFindNow.Location = new System.Drawing.Point(456, 8);
			this.btnFindNow.Name = "btnFindNow";
			this.btnFindNow.TabIndex = 18;
			this.btnFindNow.Text = "Find Now";
			this.btnFindNow.Click += new System.EventHandler(this.btnFindNow_Click);
			// 
			// dataGridAdvanceSearch
			// 
			this.dataGridAdvanceSearch.CaptionVisible = false;
			this.dataGridAdvanceSearch.ColumnHeadersVisible = false;
			this.dataGridAdvanceSearch.DataMember = "";
			this.dataGridAdvanceSearch.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridAdvanceSearch.Location = new System.Drawing.Point(16, 32);
			this.dataGridAdvanceSearch.Name = "dataGridAdvanceSearch";
			this.dataGridAdvanceSearch.ReadOnly = true;
			this.dataGridAdvanceSearch.Size = new System.Drawing.Size(432, 56);
			this.dataGridAdvanceSearch.TabIndex = 17;
			this.dataGridAdvanceSearch.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dataGridAdvanceSearch_MouseUp);
			// 
			// comboBoxAndOr
			// 
			this.comboBoxAndOr.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboBoxAndOr.Enabled = false;
			this.comboBoxAndOr.Items.AddRange(new object[] {
															   "And",
															   "Or"});
			this.comboBoxAndOr.Location = new System.Drawing.Point(16, 8);
			this.comboBoxAndOr.Name = "comboBoxAndOr";
			this.comboBoxAndOr.Size = new System.Drawing.Size(56, 21);
			this.comboBoxAndOr.TabIndex = 16;
			// 
			// textBoxSearchWord
			// 
			this.textBoxSearchWord.Enabled = false;
			this.textBoxSearchWord.Location = new System.Drawing.Point(336, 8);
			this.textBoxSearchWord.Name = "textBoxSearchWord";
			this.textBoxSearchWord.Size = new System.Drawing.Size(112, 20);
			this.textBoxSearchWord.TabIndex = 15;
			this.textBoxSearchWord.Text = "";
			this.textBoxSearchWord.TextChanged += new System.EventHandler(this.textBoxSearchWord_TextChanged);
			// 
			// comboBoxQualifier
			// 
			this.comboBoxQualifier.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboBoxQualifier.Enabled = false;
			this.comboBoxQualifier.Items.AddRange(new object[] {
																   "is equal to",
																   "is not equal to",
																   "contains",
																   "not-contains",
																   "begins with",
																   "does not begin with",
																   "is defined",
																   "is not defined"});
			this.comboBoxQualifier.Location = new System.Drawing.Point(176, 8);
			this.comboBoxQualifier.Name = "comboBoxQualifier";
			this.comboBoxQualifier.Size = new System.Drawing.Size(160, 21);
			this.comboBoxQualifier.TabIndex = 14;
			this.comboBoxQualifier.SelectedIndexChanged += new System.EventHandler(this.comboBoxQualifier_SelectedIndexChanged);
			// 
			// comboBoxProductSelector
			// 
			this.comboBoxProductSelector.ContextMenu = this.contextMenuProductSearch;
			this.comboBoxProductSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboBoxProductSelector.Enabled = false;
			this.comboBoxProductSelector.Location = new System.Drawing.Point(72, 8);
			this.comboBoxProductSelector.Name = "comboBoxProductSelector";
			this.comboBoxProductSelector.Size = new System.Drawing.Size(104, 21);
			this.comboBoxProductSelector.TabIndex = 13;
			this.comboBoxProductSelector.Click += new System.EventHandler(this.comboBoxProductSelector_Click);
			this.comboBoxProductSelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxProductSelector_SelectedIndexChanged);
			// 
			// contextMenuProductSearch
			// 
			this.contextMenuProductSearch.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																									 this.menuItemProduct});
			// 
			// menuItemProduct
			// 
			this.menuItemProduct.Index = 0;
			this.menuItemProduct.Text = "Product";
			// 
			// buttonNewAdvSearch
			// 
			this.buttonNewAdvSearch.Location = new System.Drawing.Point(16, 96);
			this.buttonNewAdvSearch.Name = "buttonNewAdvSearch";
			this.buttonNewAdvSearch.TabIndex = 10;
			this.buttonNewAdvSearch.Text = "New...";
			this.buttonNewAdvSearch.Click += new System.EventHandler(this.buttonNewAdvSearch_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.Enabled = false;
			this.btnDelete.Location = new System.Drawing.Point(104, 96);
			this.btnDelete.Name = "btnDelete";
			this.btnDelete.TabIndex = 9;
			this.btnDelete.Text = "Delete";
			this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
			// 
			// dtnEdit
			// 
			this.dtnEdit.Enabled = false;
			this.dtnEdit.Location = new System.Drawing.Point(192, 96);
			this.dtnEdit.Name = "dtnEdit";
			this.dtnEdit.TabIndex = 8;
			this.dtnEdit.Text = "Edit";
			this.dtnEdit.Click += new System.EventHandler(this.dtnEdit_Click);
			// 
			// Searchsplitter
			// 
			this.Searchsplitter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.Searchsplitter.Dock = System.Windows.Forms.DockStyle.Top;
			this.Searchsplitter.Location = new System.Drawing.Point(171, 184);
			this.Searchsplitter.Name = "Searchsplitter";
			this.Searchsplitter.Size = new System.Drawing.Size(661, 3);
			this.Searchsplitter.TabIndex = 10;
			this.Searchsplitter.TabStop = false;
			this.Searchsplitter.Visible = false;
			// 
			// Propertiespanel
			// 
			this.Propertiespanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																						  this.panelPaging,
																						  this.Navpanel});
			this.Propertiespanel.Dock = System.Windows.Forms.DockStyle.Fill;
			this.Propertiespanel.Location = new System.Drawing.Point(171, 187);
			this.Propertiespanel.Name = "Propertiespanel";
			this.Propertiespanel.Size = new System.Drawing.Size(661, 254);
			this.Propertiespanel.TabIndex = 11;
			// 
			// panelPaging
			// 
			this.panelPaging.Controls.AddRange(new System.Windows.Forms.Control[] {
																					  this.Datalist});
			this.panelPaging.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panelPaging.Name = "panelPaging";
			this.panelPaging.Size = new System.Drawing.Size(661, 222);
			this.panelPaging.TabIndex = 11;
			// 
			// Navpanel
			// 
			this.Navpanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																				   this.lblPageCount,
																				   this.lblPage,
																				   this.lblListTotal,
																				   this.lblTotalCount,
																				   this.txtPages,
																				   this.btnPrevious,
																				   this.btnNextLast,
																				   this.btnNext,
																				   this.btnPreviousLast});
			this.Navpanel.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.Navpanel.Location = new System.Drawing.Point(0, 222);
			this.Navpanel.Name = "Navpanel";
			this.Navpanel.Size = new System.Drawing.Size(661, 32);
			this.Navpanel.TabIndex = 10;
			this.Navpanel.Visible = false;
			// 
			// lblPageCount
			// 
			this.lblPageCount.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.lblPageCount.Location = new System.Drawing.Point(392, 8);
			this.lblPageCount.Name = "lblPageCount";
			this.lblPageCount.Size = new System.Drawing.Size(48, 16);
			this.lblPageCount.TabIndex = 11;
			this.lblPageCount.Visible = false;
			// 
			// lblPage
			// 
			this.lblPage.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.lblPage.Location = new System.Drawing.Point(344, 8);
			this.lblPage.Name = "lblPage";
			this.lblPage.Size = new System.Drawing.Size(40, 16);
			this.lblPage.TabIndex = 10;
			this.lblPage.Text = "Page:";
			this.lblPage.Visible = false;
			// 
			// lblListTotal
			// 
			this.lblListTotal.Location = new System.Drawing.Point(0, 8);
			this.lblListTotal.Name = "lblListTotal";
			this.lblListTotal.Size = new System.Drawing.Size(56, 16);
			this.lblListTotal.TabIndex = 3;
			this.lblListTotal.Text = "List Total:";
			this.lblListTotal.Visible = false;
			// 
			// lblTotalCount
			// 
			this.lblTotalCount.Location = new System.Drawing.Point(72, 8);
			this.lblTotalCount.Name = "lblTotalCount";
			this.lblTotalCount.Size = new System.Drawing.Size(56, 16);
			this.lblTotalCount.TabIndex = 4;
			this.lblTotalCount.Visible = false;
			// 
			// txtPages
			// 
			this.txtPages.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.txtPages.Enabled = false;
			this.txtPages.Location = new System.Drawing.Point(512, 8);
			this.txtPages.Name = "txtPages";
			this.txtPages.Size = new System.Drawing.Size(64, 20);
			this.txtPages.TabIndex = 7;
			this.txtPages.Text = "1";
			this.txtPages.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			this.txtPages.Visible = false;
			// 
			// btnPrevious
			// 
			this.btnPrevious.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.btnPrevious.Location = new System.Drawing.Point(480, 8);
			this.btnPrevious.Name = "btnPrevious";
			this.btnPrevious.Size = new System.Drawing.Size(32, 23);
			this.btnPrevious.TabIndex = 8;
			this.btnPrevious.Text = "<";
			this.btnPrevious.Visible = false;
			this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
			// 
			// btnNextLast
			// 
			this.btnNextLast.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.btnNextLast.Location = new System.Drawing.Point(608, 8);
			this.btnNextLast.Name = "btnNextLast";
			this.btnNextLast.Size = new System.Drawing.Size(32, 23);
			this.btnNextLast.TabIndex = 6;
			this.btnNextLast.Text = ">>";
			this.btnNextLast.Visible = false;
			this.btnNextLast.Click += new System.EventHandler(this.btnNextLast_Click);
			// 
			// btnNext
			// 
			this.btnNext.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.btnNext.Location = new System.Drawing.Point(576, 8);
			this.btnNext.Name = "btnNext";
			this.btnNext.Size = new System.Drawing.Size(32, 23);
			this.btnNext.TabIndex = 5;
			this.btnNext.Text = ">";
			this.btnNext.Visible = false;
			this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
			// 
			// btnPreviousLast
			// 
			this.btnPreviousLast.Anchor = System.Windows.Forms.AnchorStyles.Right;
			this.btnPreviousLast.Location = new System.Drawing.Point(448, 8);
			this.btnPreviousLast.Name = "btnPreviousLast";
			this.btnPreviousLast.Size = new System.Drawing.Size(32, 23);
			this.btnPreviousLast.TabIndex = 9;
			this.btnPreviousLast.Text = "<<";
			this.btnPreviousLast.Visible = false;
			this.btnPreviousLast.Click += new System.EventHandler(this.btnPreviousLast_Click);
			// 
			// CategorycontextMenu
			// 
			this.CategorycontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																								this.CatEdit,
																								this.EditDelete,
																								this.CatNew,
																								this.CatRefresh});
			// 
			// CatEdit
			// 
			this.CatEdit.Index = 0;
			this.CatEdit.Text = "Edit";
			this.CatEdit.Click += new System.EventHandler(this.EditCategory);
			// 
			// EditDelete
			// 
			this.EditDelete.Index = 1;
			this.EditDelete.Text = "Delete";
			this.EditDelete.Click += new System.EventHandler(this.DeleteCategory);
			// 
			// CatNew
			// 
			this.CatNew.Index = 2;
			this.CatNew.Text = "New";
			this.CatNew.Click += new System.EventHandler(this.NewCategory);
			// 
			// CatRefresh
			// 
			this.CatRefresh.Index = 3;
			this.CatRefresh.Text = "Refresh";
			this.CatRefresh.Click += new System.EventHandler(this.RefreshCategory);
			// 
			// ToolBarsplitter
			// 
			this.ToolBarsplitter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.ToolBarsplitter.Dock = System.Windows.Forms.DockStyle.Top;
			this.ToolBarsplitter.Enabled = false;
			this.ToolBarsplitter.Location = new System.Drawing.Point(0, 32);
			this.ToolBarsplitter.Name = "ToolBarsplitter";
			this.ToolBarsplitter.Size = new System.Drawing.Size(832, 3);
			this.ToolBarsplitter.TabIndex = 6;
			this.ToolBarsplitter.TabStop = false;
			// 
			// contextMenuVirtualCatalog
			// 
			this.contextMenuVirtualCatalog.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																									  this.menuItem3,
																									  this.menuItem5,
																									  this.menuItem6,
																									  this.menuItem13});
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 0;
			this.menuItem3.Text = "Edit Properties";
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 1;
			this.menuItem5.Text = "Delete Catalog";
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 2;
			this.menuItem6.Text = "Send";
			// 
			// menuItem13
			// 
			this.menuItem13.Index = 3;
			this.menuItem13.Text = "Rebuild";
			// 
			// CatalogManager
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(832, 473);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.Propertiespanel,
																		  this.Searchsplitter,
																		  this.Searchpanel,
																		  this.Cataogsplitter,
																		  this.Catalogspanel,
																		  this.ToolBarsplitter,
																		  this.Menuespanel,
																		  this.statusBarpanel});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.CatalogManagerMenu;
			this.Name = "CatalogManager";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = ".NET Catalog Editor";
			this.Load += new System.EventHandler(this.CatalogManager_Load);
			this.statusBarpanel.ResumeLayout(false);
			this.Menuespanel.ResumeLayout(false);
			this.Catalogspanel.ResumeLayout(false);
			this.Searchpanel.ResumeLayout(false);
			this.Searchtab.ResumeLayout(false);
			this.SearchtabPage.ResumeLayout(false);
			this.AdvSearchtabPage.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGridAdvanceSearch)).EndInit();
			this.Propertiespanel.ResumeLayout(false);
			this.panelPaging.ResumeLayout(false);
			this.Navpanel.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new CatalogManager());
		}

		private void CatalogManager_Load(object sender, System.EventArgs e)
		{
			// read the xml file and get the file path
			XmlDocument doc = new XmlDocument();
			doc.Load("SiteConfig.xml");
			CSService = new CatalogSystem(doc.FirstChild.InnerText);
			// load catalogs
			loadCatalogs();
		}

		/// <summary>
		/// Load all catalogs
		/// </summary>
		private void loadCatalogs()
		{
			// this would come from some configuration object
			// but for now just have defaults
			object recInQuery=null;

			// clear treeview
			CatalogTree.Nodes.Clear();

			if(SiteName==null)
			{
				SiteName=CSService.SiteName();
			}
			// Create a root node
			SiteNode tnode = new SiteNode(SiteName+" Catalog");
			tnode.ImageIndex = 0;
			tnode.SelectedImageIndex = 0;
			
			// get a list of catalogs and add them into the tree view
			DataSet ds = CSService.GetCatalogs(null, null,ref recInQuery);

			tnode.SiteProperties = ds;

			foreach(DataRow dr in ds.Tables[0].Rows)
			{
				// check to see if we have a virtual catalog
				if(dr["IsVirtualCatalog"].ToString() != "0")
				{
					VirtualCatalogNode vnode = new VirtualCatalogNode(dr);
					vnode.ImageIndex = 2;
					vnode.SelectedImageIndex = 2;
					tnode.Nodes.Add(vnode);
				}
				else
				{
					CatalogNode cnode = new CatalogNode(dr);
					cnode.ImageIndex = 1;
					cnode.SelectedImageIndex = 1;
					tnode.Nodes.Add(cnode);
				}
				// load the seach dropdown
				cboCatalogs.Items.Add(dr["CatalogName"].ToString());
			}

			// move the index to first catalog in dropdown for search
			cboCatalogs.SelectedIndex = 0;

			// display the list view
			DisplayCatalogProperties(ds, false);
			CatalogTree.Nodes.Add(tnode);
		}

		/// <summary>
		/// load categories to current node
		/// </summary>
		/// <param name="categoryNode"></param>
		/// <param name="dsCategories"></param>
		private void LoadCategories(CategoryNode categoryNode, DataSet dsCategories)
		{
			// we may have a null Category object
			if(dsCategories!=null)
			{
				foreach(DataRow dr in dsCategories.Tables[0].Rows)
				{
					// ad the data row to each node so we don't have to 
					// go to the server again
					CategoryNode  cnode = new CategoryNode(dr);
					cnode.ImageIndex = 3;
					cnode.SelectedImageIndex = 3;
					categoryNode.Nodes.Add(cnode);
				}
			}
		}

		/// <summary>
		/// load categories to current node
		/// </summary>
		/// <param name="categoryNode"></param>
		/// <param name="dsCategories"></param>
		private void LoadCategories(VirtualCatalogNode catalogNode, DataSet dsCategories)
		{
			foreach(DataRow dr in dsCategories.Tables[0].Rows)
			{
				CategoryNode  cnode = new CategoryNode(dr);
				cnode.ImageIndex = 3;
				cnode.SelectedImageIndex = 3;
				// mark it as virtual
				cnode.IsVirtual = true;
				catalogNode.Nodes.Add(cnode);
			}
		}

		/// <summary>
		/// load categories to current node
		/// </summary>
		/// <param name="categoryNode"></param>
		/// <param name="dsCategories"></param>
		private void LoadCategories(CatalogNode catalogNode, DataSet dsCategories)
		{
			foreach(DataRow dr in dsCategories.Tables[0].Rows)
			{
				CategoryNode  cnode = new CategoryNode(dr);
				cnode.ImageIndex = 3;
				cnode.SelectedImageIndex = 3;
				catalogNode.Nodes.Add(cnode);
			}
		}

		/// <summary>
		/// clear out the view
		/// </summary>
		private void ClearDatalist()
		{
			Datalist.Items.Clear();
			Datalist.Columns.Clear();
			Datalist.AllowColumnReorder = true;
			Datalist.View = View.Details;
		}

		/// <summary>
		/// Display the catalogs properties in the data list
		/// </summary>
		/// <param name="dr"></param>
		private void DisplayCatalogProperties(DataSet ds, bool page)
		{
			ClearDatalist();

			// Create columns
			Datalist.Columns.Add("Name", 125, HorizontalAlignment.Left);
			Datalist.Columns.Add("Date last updated", 125, HorizontalAlignment.Left);
			Datalist.Columns.Add("Type", 125, HorizontalAlignment.Left);
			Datalist.Columns.Add("Status", 125, HorizontalAlignment.Left);
			foreach(DataRow dr in ds.Tables[0].Rows)
			{
				ListViewItem litem = new ListViewItem(dr["CatalogName"].ToString());

				litem.StateImageIndex = 0;
				litem.ImageIndex = 0;
				litem.SubItems.Add(dr["ProductTableUpdated"].ToString());
				if(dr["IsVirtualCatalog"].ToString() == "0")
				{
					litem.SubItems.Add("Base");
				}
				else
				{
					litem.SubItems.Add("Virtual");
				}

				string catalogStatus = null;

				if(dr["IsVirtualCatalog"].ToString() != "0")
				{
					switch(dr["VirtualCatalogStatus"].ToString())
					{
						case "0":
							catalogStatus = "Requires rebuilding";
							break;
						case "1":
							catalogStatus = "Rebuilding";
							break;
						case "2":
							catalogStatus = "Rebuilt with errors";
							break;
						default:
							catalogStatus = "Up-to-date";
							break;
					}
				}
				else
				{
					catalogStatus= "";
				}
				litem.SubItems.Add(catalogStatus);
				Datalist.Items.Add(litem);
			}

			// now work with the nav object
			if(ds.Tables.Count!=0)
			{
				SetnavOptions(1, ds.Tables[0].Rows.Count, page);
			}
			else
			{
				SetnavOptions(1, 0, page);
			}
		}

		private void SetnavOptions(int StartingRec, int TotalCount, bool page)
		{
			// show the nav
			ShowHidenav(true);

			// figure out what page we are on
			if(txtPages.Text=="")
			{
				txtPages.Text="1";
			}

			// check to see if we want to page
			int TotalPages=1;

			if(page)
			{
				int currentPage = Convert.ToInt32(txtPages.Text);
				// figure out the number of pages
				TotalPages =  TotalCount / PAGE_SIZE;
				int nRemainder = TotalCount - TotalPages * PAGE_SIZE;
				if (nRemainder > 0)
				{
					TotalPages++;
				}
				if(TotalPages==0)
				{
					TotalPages=1;
				}
				lblPageCount.Text = currentPage.ToString() +"/"+TotalPages.ToString();
				lblTotalCount.Text = TotalCount.ToString();
			}
			else
			{
				lblPageCount.Text = "1/1";
				lblTotalCount.Text = TotalCount.ToString();
				txtPages.Text = StartingRec.ToString();
			}

			// enable and disable buttons
			if(TotalPages.ToString()==txtPages.Text && TotalPages !=1)
			{
				// disable the next and last buttons
				btnNext.Enabled = false;
				btnNextLast.Enabled = false;
				btnPrevious.Enabled = true;
				btnPreviousLast.Enabled = true;
			}
			else if(txtPages.Text=="1" && TotalPages !=1)
			{
				btnNext.Enabled = true;
				btnNextLast.Enabled = true;
				btnPrevious.Enabled = false;
				btnPreviousLast.Enabled = false;
			}
			else if(TotalPages ==1)
			{
				btnNext.Enabled = false;
				btnNextLast.Enabled = false;
				btnPrevious.Enabled = false;
				btnPreviousLast.Enabled = false;
			}
			else
			{
				btnNext.Enabled = true;
				btnNextLast.Enabled = true;
				btnPrevious.Enabled = true;
				btnPreviousLast.Enabled = true;
			}
		}

		private void AddToDataList(string catalogName, DataSet dsProducts)
		{
			ClearDatalist();

			// we may have null data sets
			if(dsProducts!=null)
			{
				// get the properties we are supposed to show
				DataSet ds = CSService.PropertiesToDisplayInList(catalogName);

				// Create columns
				foreach(DataRow drDisp in ds.Tables[0].Rows)
				{
					Datalist.Columns.Add(drDisp["DisplayInProductsList"].ToString(), 100, HorizontalAlignment.Left);
				}
	
				string[] lst = new string[Datalist.Columns.Count];
			
				foreach(DataRow drList in dsProducts.Tables[0].Rows)
				{
					// now iterate and get the columns
					for(int i=0;Datalist.Columns.Count>i;i++)
					{
						lst[i] = drList[Datalist.Columns[i].Text].ToString();
					}

					// create our own ProductListView so we can add more info to it
					ProductListView litem = new ProductListView(lst);
					litem.ImageIndex = 4;
					litem.StateImageIndex = 4;
					litem.CatalogName = drList["CatalogName"].ToString();
					litem.ProductID = drList["ProductID"].ToString();

					Datalist.Items.Add(litem);
				}
			}
		}

		private void Edit_Properties(object sender, System.EventArgs e)
		{
			DataRow drProperties = null;
			DataSet dsDependentCatalogs = null;
			DataSet dsLanguages = null;
			bool isVirtual = false;
			// check to see if we selecting a site or catalog
			CatalogNode cnode = CatalogTree.SelectedNode as CatalogNode;
			if(cnode!=null)
			{
				// get the languges for the catalog
				if(cnode.catLangauges==null)
				{
					dsLanguages = CSService.GetCatalogLanguages(cnode.Text);
				}
				else
				{
					dsLanguages = cnode.catLangauges;
				}
				// Get the dependant catalog
				if(cnode.DependentCatalogs==null)
				{
					dsDependentCatalogs = CSService.GetDependentCatalogs(cnode.Text);
				}
				// the node to work with
				cnode = cnode;
				drProperties = cnode.CatalogProperties;
				dsDependentCatalogs = cnode.DependentCatalogs;
			}
			else
			{
				// check to see if it's a virtual node
				VirtualCatalogNode vnode = CatalogTree.SelectedNode as VirtualCatalogNode;
				if(vnode!=null)
				{
					isVirtual=true;
				}
				else
				{
					// else get the listview
					drProperties = CSService.GetCatalog(Datalist.SelectedItems[0].Text).Tables[0].Rows[0];
					if(drProperties["IsVirtualCatalog"].ToString()=="1")
					{
						isVirtual=true;
					}
					else
					{
						dsDependentCatalogs = CSService.GetDependentCatalogs(Datalist.SelectedItems[0].Text);
						dsLanguages = CSService.GetCatalogLanguages(Datalist.SelectedItems[0].Text);
					}
				}
			}
			// what kind of catalog are we dealing with?
			if(isVirtual)
			{
				CatalogForms.VirtualCatalogEditor CatEdtrfrm = new CatalogForms.VirtualCatalogEditor();
				CatEdtrfrm.ShowDialog();
			}
			else
			{
				// get the form to edit the catalog
				CatalogForms.CatalogEditor CatEdtrfrm = new CatalogForms.CatalogEditor();
				CatEdtrfrm.drCatalogEdtitor = drProperties;
				CatEdtrfrm.CatLanguages=dsLanguages;
				CatEdtrfrm.Languages=this.Languages;
				CatEdtrfrm.Currencies = CSService.GetCurrencies();
				CatEdtrfrm.DependentCatalogs=dsDependentCatalogs;
				// show the form
				CatEdtrfrm.ShowDialog();
			}
		}

		private void Delte(object sender, System.EventArgs e)
		{
			CSService.DeleteCatalog(CatalogTree.SelectedNode.Text);
		}

		private void Send(object sender, System.EventArgs e)
		{
			CatalogForms.VendorSelector vendorselector = new CatalogForms.VendorSelector();
			// if we have a null value then get the catalog languages
			if(((CatalogNode)CatalogTree.SelectedNode).catLangauges==null)
			{
				((CatalogNode)CatalogTree.SelectedNode).catLangauges = CSService.GetCatalogLanguages(CatalogTree.SelectedNode.Text);
			}
			// if we have a null value then get all languages
			if(languages==null)
			{
				languages = CSService.GetLanguages();
			}
			vendorselector.Languages = languages;
			vendorselector.CatalogName = CatalogTree.SelectedNode.Text;
			vendorselector.catLanguages = ((CatalogNode)CatalogTree.SelectedNode).catLangauges;
			vendorselector.ShowDialog(this);
		}

		private void Rebuild(object sender, System.EventArgs e)
		{
			CSService.RegenerateFreeTextSearchIndex(CatalogTree.SelectedNode.Text);
		}

		private void Refresh(object sender, System.EventArgs e)
		{
			//
		}

		private void ShowHidefind(bool state, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			e.Button.Pushed = state;
			Searchtab.Visible = state | false;
			Searchpanel.Visible = state;
			Searchsplitter.Visible = state;
		}

		private void ShowHidenav(bool state)
		{
			Navpanel.Visible = state;
			lblTotalCount.Visible = state;
			lblListTotal.Visible = state;
			btnPreviousLast.Visible = state;
			btnPrevious.Visible = state;
			txtPages.Visible = state;
			btnNext.Visible = state;
			btnNextLast.Visible = state;
			lblPageCount.Visible = state;
			lblPage.Visible = state;
		}

		private void CatalogManagertoolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(e.Button.Text)
			{
				case "Edit Properties":
					Edit_Properties(sender, e);
					break;
				case "Delete":
					Delte(sender, e);
					break;
				case "Send":
					Send(sender, e);
					break;
				case "Rebuild":
					Rebuild(sender, e);
					break;
				case "Refresh":
					// reload catalogs
					loadCatalogs();
					break;
				case "Find":
					if(e.Button.Pushed)
					{
						// push the button and show find
						ShowHidefind(false, e);
					}
					else
					{
						// push the button and hide find
						ShowHidefind(true, e);
					}
					break;
			}
		}

		private void CatalogTree_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			// set the selected treenode
			Point p = new Point(e.X, e.Y);
			TreeNode tnode = CatalogTree.GetNodeAt(p);
			CatalogTree.SelectedNode = tnode;
			string nodetype = "";

			if(tnode!=null)
			{
				// get the type of node we are dealing with
				nodetype = tnode.GetType().ToString();
			}
			// Show menu only if Right Mouse button is clicked
			if (e.Button == MouseButtons.Right)
			{
				switch(nodetype)
				{
					case "CatalogManager.CatalogNode":
						// set the context menu
						CatalogcontextMenu.Show(CatalogTree, p);
						break;
					case "CatalogManager.VirtualCatalogNode":
						CatalogcontextMenu.Show(CatalogTree, p);
						break;
					case "CatalogManager.CategoryNode":
						// set the context menu
						CategorycontextMenu.Show(CatalogTree, p);
						break;
				}
			}
		}

		private void CatalogTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			// get the type of node we are dealing with
			string nodetype = e.Node.GetType().ToString();
			CategoryNode nextNode = null;

			// for right now just set default values
			// but we would get this from a configuration manager object
			DataSet dsProducts=null;
			object lStartingRecord=PAGE_SIZE * (Convert.ToInt32(txtPages.Text) - 1) + 1;
			object lNumRecords=PAGE_SIZE;
			object recInQuery=null;
			int idx = -1;

			switch(nodetype)
			{
					// deal with catalogs
				case "CatalogManager.CatalogNode":
					// get the node to work with
					CatalogNode cnode = (CatalogNode)e.Node;
					// if we have a catalog enable the buttons
					CatalogManagertoolBarShowHide(true);
					// check to see if need to make a call to the server					
					dsProducts = CSService.CatalogRootProducts(CatalogTree.SelectedNode.Text, lStartingRecord, lNumRecords, ref recInQuery);
					((CatalogNode)e.Node).Catalogproducts = dsProducts;
					if(dsProducts==null)
					{
						recInQuery=0;
					}
					// Get the root produts for this catalog
					AddToDataList(((CatalogNode)e.Node).CatalogProperties["CatalogName"].ToString(), dsProducts);
					// check to see if we have child nodes if not then get categories
					nextNode = (CategoryNode)cnode.FirstNode;
					if(nextNode==null)
					{
						LoadCategories(cnode, CSService.GetRootCategories(((CatalogNode)e.Node).Text));
					}
					// set the defualt product context
					//Datalist.ContextMenu = ProductcontextMenu;
					//lblTotalCount.Text = recInQuery.ToString();
					SetnavOptions(Convert.ToInt32(lStartingRecord), Convert.ToInt32(recInQuery), true);
					// set paging for nav
					paging.CatalogName=CatalogTree.SelectedNode.Text;
					paging.CategoryName=null;
					paging.Search = false;
					paging.SearchAll=false;
					// set the search catalog
					idx = cboCatalogs.Items.IndexOf(CatalogTree.SelectedNode.Text);
					cboCatalogs.SelectedIndex =  idx;
					break;
					// deal with virtual catalogs
				case "CatalogManager.VirtualCatalogNode":
					VirtualCatalogNode vnode = (VirtualCatalogNode)e.Node;
					// if we have a catalog enable the buttons
					CatalogManagertoolBarShowHide(true);
					// check to see if need to make a call to the server					
					dsProducts = CSService.CatalogRootProducts(CatalogTree.SelectedNode.Text, lStartingRecord, lNumRecords, ref recInQuery);
					vnode.Catalogproducts = dsProducts;
					if(dsProducts==null)
					{
						recInQuery=0;
					}
					AddToDataList(vnode.CatalogProperties["CatalogName"].ToString(), dsProducts);
					// check to see if we have child nodes if not then get categories
					nextNode = (CategoryNode)vnode.FirstNode;
					if(nextNode==null)
					{
						LoadCategories(vnode, CSService.GetRootCategories(vnode.Text));
					}
					// set the defualt product context
					//Datalist.ContextMenu = ProductcontextMenu;
					SetnavOptions(Convert.ToInt32(lStartingRecord), Convert.ToInt32(recInQuery), true);
					// set paging for nav
					paging.CatalogName=CatalogTree.SelectedNode.Text;
					paging.CategoryName=null;
					paging.Search = false;
					paging.SearchAll=false;
					// set the search catalog
					idx = cboCatalogs.Items.IndexOf(CatalogTree.SelectedNode.Text);
					cboCatalogs.SelectedIndex =  idx;
					break;
					// deal with categories
				case "CatalogManager.CategoryNode":
					CategoryNode catnode = (CategoryNode)e.Node;
					// if we have a categories disable the buttons
					CatalogManagertoolBarShowHide(false);
					// check to see if need to make a call to the server					
					dsProducts = CSService.RootProducts(catnode.CategoryProperty["CatalogName"].ToString(), CatalogTree.SelectedNode.Text, lStartingRecord, lNumRecords, ref recInQuery);
					//dsProducts = CSService.GetCategoryProducts(catnode.CategoryProperty["CatalogName"].ToString(), CatalogTree.SelectedNode.Text, lStartingRecord, lNumRecords, ref recInQuery);

					catnode.CategoryProducts = dsProducts;
					if(dsProducts==null)
					{
						recInQuery=0;
					}
					AddToDataList(catnode.CategoryProperty["CatalogName"].ToString(), dsProducts);
					// check to see if we have child nodes if not then get categories
					CategoryNode nextCatNode = (CategoryNode)catnode.FirstNode;
					if(nextCatNode==null)
					{
						LoadCategories(catnode, CSService.ChildCategories(catnode.CategoryProperty["CatalogName"].ToString(), catnode.Text));
					}
					// set the defualt product context
					//Datalist.ContextMenu = ProductcontextMenu;
					//lblTotalCount.Text = recInQuery.ToString();
					SetnavOptions(Convert.ToInt32(lStartingRecord), Convert.ToInt32(recInQuery), true);
					paging.CatalogName=catnode.CategoryProperty["CatalogName"].ToString();
					paging.CategoryName=catnode.Text;
					paging.Search = false;
					paging.SearchAll=false;
					// set the search catalog
					idx = cboCatalogs.Items.IndexOf(catnode.CategoryProperty["CatalogName"].ToString());
					cboCatalogs.SelectedIndex =  idx;
					break;
				default:
					// if we have noting disable the buttons
					DisplayCatalogProperties(((SiteNode)e.Node).SiteProperties, false);
					CatalogTree.ContextMenu = null;
					//Datalist.ContextMenu = CatalogcontextMenu;
					CatalogManagertoolBarShowHide(false);
					paging.CatalogName=null;
					paging.CategoryName=null;
					paging.Search = false;
					paging.SearchAll=false;
					break;
			}		
		}

		private void CatalogManagertoolBarShowHide(bool state)
		{
			foreach(ToolBarButton btn in CatalogManagertoolBar.Buttons)
			{
				if(btn.Text!="New")
				{
					btn.Enabled = state;
				}
			}
		}

		/// <summary>
		/// Get the all languages
		/// </summary>
		public DataSet Languages
		{
			get
			{
				if(languages==null)
				{
					languages = CSService.GetLanguages();
				}
				return languages;
			}
		}
		
		private void EditProduct(object sender, System.EventArgs e)
		{
			// find out what the user selected since we only allow a single select always get the first one
			ProductListView PrdListView =(ProductListView)Datalist.SelectedItems[0];
			// get the product data
			DataSet ds = CSService.GetProduct(PrdListView.CatalogName, PrdListView.ProductID);
			ProductForms.ProductEditor Prd = new ProductForms.ProductEditor();
			Prd.catalogName = PrdListView.CatalogName;
			Prd.ProductProperties = ds;
			Prd.ShowDialog(this);
		}

		private void DeleteProduct(object sender, System.EventArgs e)
		{
			//
		}

		private void Search(string strSQLClause, string strFTSPhrase, string strCatalogsToSearch, string eClassTypeRequired, string lStartingRecord)
		{
			// clear the datalist and set details
			ClearDatalist();
			// get the properties we are supposed to show
			DataSet ds = CSService.PropertiesToDisplayInList(cboCatalogs.Text);
			// Create columns
			string propertiesToReturn=null;
			foreach(DataRow drDisp in ds.Tables[0].Rows)
			{
				Datalist.Columns.Add(drDisp["DisplayInProductsList"].ToString(), 100, HorizontalAlignment.Left);
				// build properties to return
				propertiesToReturn+=drDisp["DisplayInProductsList"].ToString()+",";
			}
			// build the search
			propertiesToReturn=propertiesToReturn.Remove(propertiesToReturn.Length-1,1);
			//string productID = CatalogTree.Nodes;
			// search
			object lTotalRecordsInQuery=null;
			string ProductID=null;
			string VariantID=null;
			CSService.GetIdentifyingProperties(ref ProductID, ref VariantID, cboCatalogs.Text);
			ds = CSService.Search(strSQLClause, strFTSPhrase, strCatalogsToSearch, eClassTypeRequired, propertiesToReturn, ProductID, true, lStartingRecord, PAGE_SIZE.ToString(), null, ref lTotalRecordsInQuery);
			// populate the data list
			AddToDataList(strCatalogsToSearch, ds);
			SetnavOptions(1, Convert.ToInt32(lTotalRecordsInQuery), true);
		}

		/// <summary>
		/// find all products for current selected catalog
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void FindAllProduct(object sender, System.EventArgs e)
		{
			txtPages.Text = "1";
			Search("(i_ClassType > 0)", null , cboCatalogs.Text, "28", "1");
			paging.Search = true;
			paging.SearchAll=true;
		}

		private void FindProduct(object sender, System.EventArgs e)
		{
			txtPages.Text = "1";
			// do a keyword search
			// first check to see if we have a blank field for keyword
			if(txtKeyWord.Text!="")
			{
				Search(null, txtKeyWord.Text, cboCatalogs.Text, "28", "1");
				paging.Search = true;
				paging.SearchAll=false;
			}
			else
			{
				ShowHidefind(true, new System.Windows.Forms.ToolBarButtonClickEventArgs(CatalogManagertoolBar.Buttons[9]));
			}
		}

		private void NewProduct(object sender, System.EventArgs e)
		{
			// need to know where to create the product
			CatalogForms.CatalogSelector catSelector = new CatalogForms.CatalogSelector();
			catSelector.ShowDialog(this);

			if(catSelector.CatalogName!=null)
			{
				// need to show the definitions avaialble
				ProductForms.ProductDefintion ProdDef = new ProductForms.ProductDefintion();
				ProdDef.ShowDialog(this);
			
				if(ProdDef.Defintion!=null)
				{
					ProductForms.ProductEditor Prd = new ProductForms.ProductEditor();
					Prd.NewProduct = true;
					Prd.DefinitionName = ProdDef.Defintion;
					Prd.catalogName = catSelector.CatalogName;
					Prd.ShowDialog(this);
				}
			}
		}

		private void NewCategory(object sender, System.EventArgs e)
		{
			// need to get defintion to work with
			CategoryForms.CategoryDefintion CatDef = new CategoryForms.CategoryDefintion();
			CatDef.ShowDialog(this);
			if(CatDef.SelectCategoryDef!=null)
			{
				CategoryForms.CategoryEditor cat = new CategoryForms.CategoryEditor();
				cat.ShowDialog(this);
			}
		}

		private void EditCategory(object sender, System.EventArgs e)
		{
			// get selected category
			// first check to see if we have a node
			CategoryNode catnode = (CategoryNode)CatalogTree.SelectedNode as CategoryNode;

			// if it's not a node then check to see if we have a list
			if(catnode!=null)
			{
				//

				// edit selected category
				CategoryForms.CategoryEditor cat = new CategoryForms.CategoryEditor();
				// get the category and display the form
				cat.CategoryProperties = CSService.GetCategory(catnode.CategoryProperty["CatalogName"].ToString(), catnode.Text);
				cat.ShowDialog(this);
			}
		}

		private void DeleteCategory(object sender, System.EventArgs e)
		{
			// delete selected category
		}

		private void RefreshCategory(object sender, System.EventArgs e)
		{
			// referesh category
		}

		private void menuItemCatalogASets_Click(object sender, System.EventArgs e)
		{
			// show catalog sets
			CatalogDefintion.CatalogSets catSet = new CatalogDefintion.CatalogSets();
			catSet.ShowDialog(this);
		}

		private void menuItemCategoryDef_Click(object sender, System.EventArgs e)
		{
			// show Category Defintion
			CatalogDefintion.CategoryDefintion catDef = new CatalogDefintion.CategoryDefintion();
			catDef.ShowDialog(this);
		}

		private void menuItemProductDef_Click(object sender, System.EventArgs e)
		{
			// show Product Definition
			CatalogDefintion.ProductDefinition ProdDef = new CatalogDefintion.ProductDefinition();
			ProdDef.ShowDialog(this);
		}

		private void menuItem1PropertyDef_Click(object sender, System.EventArgs e)
		{
			// show Property Definition
			CatalogDefintion.PropertyDefinition PropDef = new CatalogDefintion.PropertyDefinition();
			PropDef.ShowDialog(this);
		}

		private void buttonNewAdvSearch_Click(object sender, System.EventArgs e)
		{
			// check to see if we have more than one record in the datagrid if so then enable the and/or dropdown
			if(dsSearch!=null)
			{
				if(dsSearch.Tables[0].Rows.Count>0)
				{
					comboBoxAndOr.Enabled = true;
					comboBoxAndOr.SelectedIndex =0;
				}
			}
			// now enable the comboBoxProductSelector
			comboBoxProductSelector.Enabled = true;
			btnDelete.Enabled = false;
			dtnEdit.Enabled = false;
			btnCancel.Enabled = true;
		}

		private void comboBoxProductSelector_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			// now enable the comboBoxQualifier
			comboBoxQualifier.Enabled = true;
		}

		private void comboBoxQualifier_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			// now enable the textBoxSearchWord
			textBoxSearchWord.Enabled = true;
		}

		private void btnApply_Click(object sender, System.EventArgs e)
		{
			// move all the data into the gird and disable the search controls
			ShowHideSearchControls(false);
			dataGridAdvanceSearch.DataSource = null;

			if(!haveSearchData)
			{
				// now add the data into the grid
				dsSearch = new DataSet();
				dsSearch.Tables.Add(new DataTable());
				dsSearch.Tables[0].Columns.Add("AndOr", typeof(string));
				dsSearch.Tables[0].Columns.Add("ProductSelector", typeof(string));
				dsSearch.Tables[0].Columns.Add("Qualifier", typeof(string));
				dsSearch.Tables[0].Columns.Add("SearchWord", typeof(string));
			}
			
			if(editRow)
			{
				// we must be updaing
				drSearch["AndOr"]=(string)comboBoxAndOr.SelectedItem;
				drSearch["ProductSelector"]=(string)comboBoxProductSelector.SelectedItem;
				drSearch["Qualifier"]=(string)comboBoxQualifier.SelectedItem;
				drSearch["SearchWord"]=(string)textBoxSearchWord.Text;
			}
			else
			{
				// just add a new row
				DataRow dr = dsSearch.Tables[0].NewRow();
				dr["AndOr"]=(string)comboBoxAndOr.SelectedItem;
				dr["ProductSelector"]=(string)comboBoxProductSelector.SelectedItem;
				dr["Qualifier"]=(string)comboBoxQualifier.SelectedItem;
				dr["SearchWord"]=(string)textBoxSearchWord.Text;
				dsSearch.Tables[0].Rows.Add(dr);
			}
			
			dataGridAdvanceSearch.DataSource = dsSearch.Tables[0];
			haveSearchData=true;

			// now that we have the data in the grid lets clean up
			comboBoxAndOr.SelectedIndex =-1;
			comboBoxProductSelector.SelectedIndex=-1;
			comboBoxQualifier.SelectedIndex=-1;
			textBoxSearchWord.Text="";

			ShowHideSearchControls(false);
		}

		private void ShowHideSearchControls(bool state)
		{
			comboBoxAndOr.Enabled = state;
			comboBoxProductSelector.Enabled = state;
			comboBoxQualifier.Enabled = state;
			textBoxSearchWord.Enabled = state;
			btnDelete.Enabled = state;
			dtnEdit.Enabled = state;
			btnApply.Enabled = state;
			btnCancel.Enabled = state;
		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			// remove the selected record from the datagrid
			dsSearch.Tables[0].Rows.Remove(drSearch);
			btnDelete.Enabled = false;
			dtnEdit.Enabled = false;
			btnApply.Enabled = false;
			btnCancel.Enabled = false;
		}

		private void dtnEdit_Click(object sender, System.EventArgs e)
		{
			// edit the select data in datagrid
			comboBoxAndOr.SelectedIndex = comboBoxAndOr.FindStringExact(drSearch["AndOr"].ToString());
			comboBoxProductSelector.Items.Clear();
			comboBoxProductSelector.Items.Add(drSearch["ProductSelector"].ToString());
			comboBoxProductSelector.SelectedIndex=0;
			comboBoxQualifier.SelectedIndex=comboBoxQualifier.FindStringExact(drSearch["Qualifier"].ToString());
			textBoxSearchWord.Text=drSearch["SearchWord"].ToString();
			editRow=true;
			btnCancel.Enabled = true;

			comboBoxProductSelector.Enabled = true;
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			comboBoxAndOr.SelectedIndex =-1;
			comboBoxProductSelector.Items.Remove(comboBoxProductSelector.SelectedItem);
			comboBoxProductSelector.SelectedIndex =-1;
			comboBoxProductSelector.Enabled = false;
			comboBoxQualifier.SelectedIndex =-1;
			comboBoxQualifier.Enabled = false;
			textBoxSearchWord.Text = "";
			textBoxSearchWord.Enabled = false;

			// undo what the user started
			comboBoxAndOr.Enabled = false;
			comboBoxProductSelector.Enabled = false;
			comboBoxQualifier.Enabled = false;
			textBoxSearchWord.Enabled = false;

			btnApply.Enabled = false;
			dtnEdit.Enabled = false;
			btnDelete.Enabled = false;
			btnCancel.Enabled = false;
		}

		private void btnFindNow_Click(object sender, System.EventArgs e)
		{
			// parse the advance query
			DataTable tb = (DataTable)dataGridAdvanceSearch.DataSource;
			string SQLSearch="";

			foreach(DataRow dr in tb.Rows)
			{
				if(dr["AndOr"]!=System.DBNull.Value)
				{
					SQLSearch+=dr["AndOr"].ToString();
				}
				SQLSearch+=" "+dr["ProductSelector"].ToString()+QualifyQery(dr["Qualifier"].ToString(), dr["SearchWord"].ToString())+" ";
			}

			MessageBox.Show(SQLSearch);

			try
			{
				Search(SQLSearch, null, cboCatalogs.Text, "28", "1");
			}
			catch{}

			// do a search based on users search ceriteria
			txtPages.Text = "1";
		}

		private string QualifyQery(string qualifierText, string qualifierValue)
		{
			string Qulify=null;

			switch(qualifierText)
			{
				case "is equal to":
					Qulify="='"+qualifierValue+"'";
					break;
				case "is not equal to":
					Qulify="<>'"+qualifierValue+"'";
					break;
				case "contains":
					Qulify="LIKE '%"+qualifierValue+"%'";
					break;
				case "not-contains":
					Qulify="NOT LIKE '%"+qualifierValue+"%'";
					break;
				case "begins with":
					Qulify="LIKE '%"+qualifierValue+"'";
					break;
				case "does not begin with":
					Qulify="NOT LIKE '%"+qualifierValue+"'";
					break;
				case "is defined":
					Qulify="IS NOT NULL";
					break;					
				case "is not defined":
					Qulify="IS NULL";
					break;
			}
			return Qulify;
		}

		private void comboBoxProductSelector_Click(object sender, System.EventArgs e)
		{
			//check to see if we have any submenus
			if(contextMenuProductSearch.MenuItems[0].MenuItems.Count==0)
			{
				// get a list of properties
				DataSet ds = CSService.GetProperties(cboCatalogs.Text);
				// load defintions
				foreach(DataRow dr in ds.Tables[0].Rows)
				{
					PropertyMenuItem mi = new PropertyMenuItem(dr["PropertyName"].ToString(), new System.EventHandler(this.dynamicMenu_Click)); 
					mi.DrProperty = dr;
					contextMenuProductSearch.MenuItems[0].MenuItems.Add(mi);
				}
			}
			contextMenuProductSearch.Show(comboBoxProductSelector,System.Drawing.Point.Empty);
		}

		private void dynamicMenu_Click(object sender, System.EventArgs e)
		{    
			// the user clicked our dynamic menu
			comboBoxProductSelector.Items.Clear();
			comboBoxProductSelector.Items.Add(((MenuItem)sender).Text);
			comboBoxProductSelector.SelectedIndex = 0;
		}

		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			// for testing only
			comboBoxProductSelector.Items.Clear();
			comboBoxProductSelector.Items.Add("ProductID");
			comboBoxProductSelector.SelectedIndex=0;
		}

		private void textBoxSearchWord_TextChanged(object sender, System.EventArgs e)
		{
			// check to see if the lenght is greater than one if so enable the apply button
			if(textBoxSearchWord.Text.Length>=1)
			{
				btnApply.Enabled = true;
			}
		}

		private void dataGridAdvanceSearch_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			DataGrid SearchGrid = (DataGrid)sender;
			SearchHitInfo = SearchGrid.HitTest(e.X, e.Y);

			switch(SearchHitInfo.Type)
			{
				case DataGrid.HitTestType.RowHeader:
					btnDelete.Enabled = true;
					dtnEdit.Enabled = true;
					btnCancel.Enabled = false;
					// now get the selected row
					DataTable dt = (DataTable)SearchGrid.DataSource;
					drSearch = dt.Rows[SearchHitInfo.Row];
					break;
				default:
					btnDelete.Enabled = false;
					dtnEdit.Enabled = false;
					btnCancel.Enabled = false;
					break;
			}

		}

		private string catalogPropertiesToReturn()
		{
			// get the properties we are supposed to show
			DataSet ds = CSService.PropertiesToDisplayInList(cboCatalogs.Text);
			// Create columns
			string propertiesToReturn=null;
			foreach(DataRow drDisp in ds.Tables[0].Rows)
			{
				Datalist.Columns.Add(drDisp["DisplayInProductsList"].ToString(), 100, HorizontalAlignment.Left);
				// build properties to return
				propertiesToReturn+=drDisp["DisplayInProductsList"].ToString()+",";
			}
			// build the search
			return propertiesToReturn.Remove(propertiesToReturn.Length-1,1);
		}

		private void getPagingProducts(object lStartingRecord, ref object recInQuery)
		{
			DataSet dsProducts=null;

			if(!paging.Search)
			{
				// what are we dealing with
				if(paging.CategoryName!=null)
				{
					dsProducts = CSService.RootProducts(paging.CatalogName, paging.CategoryName, lStartingRecord, PAGE_SIZE, ref recInQuery);
					AddToDataList(paging.CatalogName, dsProducts);
					SetnavOptions(Convert.ToInt32(lStartingRecord), Convert.ToInt32(recInQuery), true);
				}
				else
				{
					// if we don't have a category then we are looking for root products
					dsProducts = CSService.CatalogRootProducts(paging.CatalogName, lStartingRecord, PAGE_SIZE, ref recInQuery);
					AddToDataList(paging.CatalogName, dsProducts);
					SetnavOptions(Convert.ToInt32(lStartingRecord), Convert.ToInt32(recInQuery), true);
					// just in case we came from a category clear it out
					paging.CategoryName = null;
				}
			}
			else
			{
				// clear the datalist and set details
				ClearDatalist();

				string propertiesToReturn=catalogPropertiesToReturn();

				// what kind of search are we doing
				if(paging.SearchAll)
				{
					Search("(i_ClassType > 0)", null , cboCatalogs.Text, "28", lStartingRecord.ToString());
					paging.Search = true;
					paging.SearchAll=true;
				}
				else
				{
					// keyword search
					// first check to see if we have a blank field for keyword
					if(txtKeyWord.Text!="")
					{
						Search(null, txtKeyWord.Text, cboCatalogs.Text, "28", lStartingRecord.ToString());
						paging.Search=true;
						paging.SearchAll=false;
					}
					else
					{
						ShowHidefind(true, new System.Windows.Forms.ToolBarButtonClickEventArgs(CatalogManagertoolBar.Buttons[9]));
					}
				}
			}
		}

		private void btnNext_Click(object sender, System.EventArgs e)
		{
			// really need to clean this up
			// go to next page
			// get the starting record
			object recInQuery=null;
			object lStartingRecord=(PAGE_SIZE * Convert.ToInt32(txtPages.Text))+1;
			
			// now increment our page
			int nPage = Convert.ToInt32(txtPages.Text);

			nPage++;
			txtPages.Text=nPage.ToString();

			// get products
			getPagingProducts(lStartingRecord, ref recInQuery);
		}

		private void btnNextLast_Click(object sender, System.EventArgs e)
		{
			// go to first page
			// really need to clean this up
			// get the starting record
			object recInQuery=null;
			// if we are going to the first page our starting record is always one
			object lStartingRecord=(Convert.ToInt32(lblTotalCount.Text)-PAGE_SIZE)+1;
			
			int TotalPages =  Convert.ToInt32(lblTotalCount.Text) / PAGE_SIZE;
			int nRemainder = Convert.ToInt32(lblTotalCount.Text) - TotalPages * PAGE_SIZE;
			if (nRemainder > 0)
			{
				TotalPages++;
			}
			if(TotalPages==0)
			{
				TotalPages=1;
			}
			txtPages.Text=TotalPages.ToString();
			getPagingProducts(lStartingRecord, ref recInQuery);
		}

		private void btnPrevious_Click(object sender, System.EventArgs e)
		{
			// go to previous page
			// get the starting record
			object recInQuery=null;
			// if we are going to the first page our starting record is always one
			object lStartingRecord=((PAGE_SIZE * (Convert.ToInt32(txtPages.Text) - 1) +1)-PAGE_SIZE);

			// now decrement our page
			int nPage = Convert.ToInt32(txtPages.Text);
			nPage--;
			txtPages.Text=nPage.ToString();
	
			getPagingProducts(lStartingRecord, ref recInQuery);
		}

		private void btnPreviousLast_Click(object sender, System.EventArgs e)
		{
			// go to first page
			// really need to clean this up
			// get the starting record
			object recInQuery=null;
			// if we are going to the first page our starting record is always one
			object lStartingRecord=1;
			txtPages.Text="1";
			getPagingProducts(lStartingRecord, ref recInQuery);
		}

		private void Datalist_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			try
			{
				Point p = new Point(e.X, e.Y);
				ProductListView litem = Datalist.SelectedItems[0] as ProductListView;
				
				if(e.Button == MouseButtons.Right)
				{
					if(litem!=null)
					{
						ProductcontextMenu.Show(Datalist, p);
					}
					else
					{
						CatalogcontextMenu.Show(Datalist, p);
					}
				}
			}
			catch{}
		}

		private void menuItemNewBase_Click(object sender, System.EventArgs e)
		{
			CatalogForms.CatalogEditor ctlgEditor = new CatalogForms.CatalogEditor();
			ctlgEditor.newCatalog = true;
			ctlgEditor.ShowDialog(this);
		}

		private void menuItemNewVirtual_Click(object sender, System.EventArgs e)
		{
			CatalogForms.VirtualCatalogEditor ctlgEditor = new CatalogForms.VirtualCatalogEditor();
			ctlgEditor.ShowDialog(this);		
		}

		private void menuItem1ExportXML_Click(object sender, System.EventArgs e)
		{
			CatalogForms.ExportCatalog ctlgExportXML = new CatalogForms.ExportCatalog();
			ctlgExportXML.ShowDialog(this);
		}

		private void menuItem1ExportCSV_Click(object sender, System.EventArgs e)
		{
			CatalogForms.ExportCatalog ctlgExportXML = new CatalogForms.ExportCatalog();
			ctlgExportXML.ShowDialog(this);
		}

		private void menuItemImportXML_Click(object sender, System.EventArgs e)
		{
			CatalogForms.ImportCatalog ctlgImportXML = new CatalogForms.ImportCatalog();
			ctlgImportXML.ShowDialog(this);
		}

		private void menuItemImportCSV_Click(object sender, System.EventArgs e)
		{
			CatalogForms.ImportCatalog ctlgImportXML = new CatalogForms.ImportCatalog();
			ctlgImportXML.ShowDialog(this);
		}
	}
}